<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Class 的 继承</title>
</head>

<body>
    <script>
        // ES5 通过修改原型链实现继承，Class 可以通过extends 关键字实现继承。
        class Point {

        }
        class ColorPoint extends Point {
            constructor(x, y, color) {
                super(x, y) //调用父类的constructor(x,y)
                this.color = color;
            }
            toString() {
                return this.color + ' ' + super.toString();
            }
        }

        class A {
            constructor() {
                this.p = 2
            }
        }

        class B extends A {
            get m() {
                return super.p
            }
        }
        let b = new B()
        console.log(b.m)
        console.log(b.p)
    </script>
</body>

</html>